import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from './views/Home.vue'
import Message from './views/Message.vue'
import Planet from './views/Planet.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    meta: {
      index: 0
    }
  },
  {
    path: '/message',
    name: 'Message',
    component: Message,
    meta: {
      index: 1
    }
  },
  {
    path: '/planet',
    name: 'Planet',
    component: Planet,
    meta: {
      index: 2
    }
  }
]

const router = new VueRouter({
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    }
    return { x: 0, y: 0 }
  }
})

export default router 